package com.sky.controller.user;

import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.result.Result;
import com.sky.service.DishService;
import com.sky.service.SetmealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user/setmeal")
public class UserSetmealController {
    @Autowired
    private SetmealService setmealService;
    @Autowired
    private DishService dishService;

    @GetMapping("/list")
    public Result listBycategoryId(@RequestParam Integer categoryId){
        List<Setmeal> setmeals = setmealService.listBycategoryId(categoryId);
        return Result.success(setmeals);
    }

    @GetMapping("/dish/{id}")
    public Result listDishBySetmealId(@PathVariable Integer id){
        List<Dish> dishList = dishService.listDishBySetmealId(id);
        return Result.success(dishList);
    }
}
